/*
 权限管理接口封装
*/
import {request} from '../utils/reequest'
// 所有权限列表
export const getRights = () =>{
  return request({
    method:'GET',
    url:`rights/list`
  })
}
// 角色列表
export const getRoles = ()=>{
  return request({
    method:'GET',
    url:'roles'
  })
}
// 添加角色
export const postRoles = params =>{
  return request({
    method:'POST',
    url:'roles',
    data:{
      roleDesc:params.roleDesc,
      roleName:params.roleName
    }
  })
}
// 编辑角色
export const getRolesId = ID =>{
  return request({
    method:'GET',
    url:`roles/${ID}`
  })
}
//编辑提交角色
export const putRolesId = params =>{
  return request({
   method:'PUT',
   url:`roles/${params.roleId}`,
   data:{
    roleDesc:params.roleDesc,
    roleName:params.roleName
   }
  })
}
// 删除角色
export const deleteRolesId =ID =>{
  console.log(ID, '删除角色')
  return request({
    method:'delete',
    url:`roles/${ID}`
  })
}
//  删除角色指定权限
export const deleteRolesRoleId = (roleId,rightId) =>{
  // console.log(roleId, '删除角色指定权限')
  // console.log(rightId, '删除角色指定权限2')
  return request({
    method:'delete',
    url:`roles/${roleId}/rights/${rightId}`
  })
}
// 分配权限
export const gitRightsTree = ()=>{
  return request({
    method:'Get',
    url:`rights/tree`
  })
}
// 角色授权
export const postRolesRoleIdRights = (roleId,IdStr) =>{
  return request({
    method:'POST',
    url:`roles/${roleId}/rights`,
    data:{
      rids:IdStr
    }
  })
}
